﻿Public Class Rdevolucion

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32, ByVal idEtapa As Int32) As List(Of Edevolucion)
        Dim devoluciones As List(Of Edevolucion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                devoluciones = Ddevolucion.SeleccionarTodo(descEmpresa, idProyecto, idEtapa)
                If devoluciones Is Nothing Then devoluciones = New List(Of Edevolucion)
                If DisplaySelect Then devoluciones.Insert(0, New Edevolucion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return devoluciones
    End Function
    Public Shared Function SeleccionarFiltro(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal devolucion As Edevolucion) As List(Of Edevolucion)
        Dim devoluciones As List(Of Edevolucion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                devoluciones = Ddevolucion.SeleccionarFiltro(descEmpresa, idProyecto, idEtapa, devolucion)
                If devoluciones Is Nothing Then devoluciones = New List(Of Edevolucion)
                If DisplaySelect Then devoluciones.Insert(0, New Edevolucion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return devoluciones
    End Function
    'Public Shared Function SeleccionarXEstado(ByVal DisplaySelect As Boolean) As List(Of Evendedor)
    '    Dim vendedors As List(Of Evendedor) = Nothing

    '    Dim options As New TransactionOptions
    '    options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
    '    options.Timeout = New TimeSpan(0, 2, 0)

    '    Using scope As New TransactionScope(TransactionScopeOption.Required, options)
    '        Try
    '            vendedors = Dvendedor.SeleccionarXEstado
    '            If vendedors Is Nothing Then vendedors = New List(Of Evendedor)
    '            If DisplaySelect Then vendedors.Insert(0, New Evendedor("00", "-- SELECIONAR --"))
    '            scope.Complete()
    '        Catch ex As Exception
    '            Throw
    '        End Try
    '    End Using

    '    Return vendedors
    'End Function
    'Public Shared Function Añadir(ByVal pVendedor As Evendedor) As Boolean
    '    Dim resultado As Boolean = False

    '    Dim options As New TransactionOptions
    '    options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
    '    options.Timeout = New TimeSpan(0, 2, 0)

    '    Using scope As New TransactionScope(TransactionScopeOption.Required, options)
    '        Try
    '            resultado = Dvendedor.Añadir(pVendedor)
    '            scope.Complete()
    '        Catch ex As Exception
    '            Throw
    '        End Try
    '    End Using

    '    Return resultado
    'End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal devolucion As Edevolucion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddevolucion.Añadir(descEmpresa, devolucion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirTemp(ByVal descEmpresa As String, ByVal devolucion As Edevolucion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddevolucion.AñadirTemp(descEmpresa, devolucion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pDevolucion As Edevolucion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddevolucion.Editar(descEmpresa, pDevolucion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    'Public Shared Function Eliminar(ByVal pVendedor As Evendedor) As Boolean
    '    Dim resultado As Boolean = False

    '    Dim options As New TransactionOptions
    '    options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
    '    options.Timeout = New TimeSpan(0, 2, 0)

    '    Using scope As New TransactionScope(TransactionScopeOption.Required, options)
    '        Try
    '            resultado = Dvendedor.Eliminar(pVendedor)
    '            scope.Complete()
    '        Catch ex As Exception
    '            Throw
    '        End Try
    '    End Using

    '    Return resultado
    'End Function

    Public Shared Function SeleccionarTodoTemporal(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32, ByVal idEtapa As Int32) As List(Of Edevolucion)
        Dim devoluciones As List(Of Edevolucion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                devoluciones = Ddevolucion.SeleccionarTodoTemporal(descEmpresa, idProyecto, idEtapa)
                If devoluciones Is Nothing Then devoluciones = New List(Of Edevolucion)
                If DisplaySelect Then devoluciones.Insert(0, New Edevolucion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return devoluciones
    End Function
    Public Shared Function AñadirTemporal(ByVal descEmpresa As String, ByVal devolucion As Edevolucion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddevolucion.AñadirTemporal(descEmpresa, devolucion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarTemporal(ByVal descEmpresa As String, ByVal pDevolucion As Edevolucion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddevolucion.EditarTemporal(descEmpresa, pDevolucion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
